package com.example.classcommunity3.dao;

import com.example.classcommunity3.model.Subject;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import javax.transaction.Transactional;
import java.util.List;

public interface SubjectDao extends JpaRepository<Subject, Long> {

    Subject findBySubCode(String subCode);

    List<Subject> findBySubTAccount(Long account);

    @Transactional
    @Modifying
    @Query(nativeQuery = true, value ="DELETE FROM subject WHERE subject.sub_code = ?1" )
    int deleteBySubCode(String subCode);
}
